package nina.yiyou.attendance.s20sum.output.salary

import groovy.transform.PackageScope
import nina.yiyou.attendance.s30pattern.output.excel.OutXlsxWriter

import java.nio.file.Path
import java.util.stream.Collectors

@PackageScope
class SumExcelExporter {

  SumExcelExporter(Path excelPath, List<String> keyList, List<Map> employeeList) {
    _excelPath = excelPath
    _keyList = keyList
    _employeeList = employeeList
  }

  void export() {
    new OutXlsxWriter(_excelPath, _keyList, _employeeList.stream()
        .map { Map e -> _keyList.collect { e[it] } }
        .collect(Collectors.toList())).write()
  }

  private final Path _excelPath

  private final List<String> _keyList
  private final List<Map> _employeeList
}
